package com.kehutong.wxapi.request;

import org.coraframework.json.annotation.JSONField;

import java.util.List;

/**
 * 创建企业群发请求对象
 * @author: liukunlong
 * @date: 2021-03-05 10:35
 */
public class AddMsgTemplateRequest {
    /**
     * 调用接口凭证
     */
    private String accessToken;
    /**
     * 群发任务的类型，默认为single，表示发送给客户，group表示发送给客户群
     */ /**
     * chat_type : single
     * external_userid : ["woAJ2GCAAAXtWyujaWJHDDGi0mACAAAA","wmqfasd1e1927831123109rBAAAA"]
     * sender : zhangsan
     * text : {"content":"文本消息内容"}
     * image : {"media_id":"MEDIA_ID","pic_url":"http://p.qpic.cn/pic_wework/3474110808/7a6344sdadfwehe42060/0"}
     * link : {"title":"消息标题","picurl":"https://example.pic.com/path","desc":"消息描述","url":"https://example.link.com/path"}
     * miniprogram : {"title":"消息标题","pic_media_id":"MEDIA_ID","appid":"wx8bd80126147dfAAA","page":"/path/index.html"}
     */

    @JSONField(name = "chat_type")
    private String chatType;
    /**
     * 客户的外部联系人id列表，仅在chat_type为single时有效，不可与sender同时为空，最多可传入1万个客户
     */
    @JSONField(name = "external_userid")
    private List<String> externalUserid;
    /**
     * 发送企业群发消息的成员userid，当类型为发送给客户群时必填
     */
    @JSONField(name = "sender")
    private String sender;
    /**
     * 消息文本对象
     */
    @JSONField(name = "text")
    private TextDTO text;
    /**
     * 图片对象
     */
    @JSONField(name = "image")
    private ImageDTO image;
    /**
     * 图文消息对象
     */
    @JSONField(name = "link")
    private LinkDTO link;
    /**
     * 小程序消息对象
     */
    @JSONField(name = "miniprogram")
    private MiniprogramDTO miniprogram;


    public String getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

    public String getChatType() {
        return chatType;
    }

    public void setChatType(String chatType) {
        this.chatType = chatType;
    }

    public List<String> getExternalUserid() {
        return externalUserid;
    }

    public void setExternalUserid(List<String> externalUserid) {
        this.externalUserid = externalUserid;
    }

    public String getSender() {
        return sender;
    }

    public void setSender(String sender) {
        this.sender = sender;
    }

    public TextDTO getText() {
        return text;
    }

    public void setText(TextDTO text) {
        this.text = text;
    }

    public ImageDTO getImage() {
        return image;
    }

    public void setImage(ImageDTO image) {
        this.image = image;
    }

    public LinkDTO getLink() {
        return link;
    }

    public void setLink(LinkDTO link) {
        this.link = link;
    }

    public MiniprogramDTO getMiniprogram() {
        return miniprogram;
    }

    public void setMiniprogram(MiniprogramDTO miniprogram) {
        this.miniprogram = miniprogram;
    }

    public static class TextDTO {
        /**
         * 消息文本内容，最多4000个字节
         */ /**
         * content : 文本消息内容
         */

        @JSONField(name = "content")
        private String content;

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }
    }

    public static class ImageDTO {
        /**
         * 图片的media_id，可以通过素材管理接口获得
         */ /**
         * media_id : MEDIA_ID
         * pic_url : http://p.qpic.cn/pic_wework/3474110808/7a6344sdadfwehe42060/0
         */

        @JSONField(name = "media_id")
        private String mediaId;
        /**
         * 图片的链接，仅可使用上传图片接口得到的链接
         */
        @JSONField(name = "pic_url")
        private String picUrl;

        public String getMediaId() {
            return mediaId;
        }

        public void setMediaId(String mediaId) {
            this.mediaId = mediaId;
        }

        public String getPicUrl() {
            return picUrl;
        }

        public void setPicUrl(String picUrl) {
            this.picUrl = picUrl;
        }
    }

    public static class LinkDTO {
        /**
         * 图文消息标题
         */ /**
         * title : 消息标题
         * picurl : https://example.pic.com/path
         * desc : 消息描述
         * url : https://example.link.com/path
         */

        @JSONField(name = "title")
        private String title;
        /**
         * 图文消息封面的url
         */
        @JSONField(name = "picurl")
        private String picurl;
        /**
         * 图文消息的描述，最多512个字节
         */
        @JSONField(name = "desc")
        private String desc;
        /**
         * 图文消息的链接
         */
        @JSONField(name = "url")
        private String url;

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getPicurl() {
            return picurl;
        }

        public void setPicurl(String picurl) {
            this.picurl = picurl;
        }

        public String getDesc() {
            return desc;
        }

        public void setDesc(String desc) {
            this.desc = desc;
        }

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }
    }

    public static class MiniprogramDTO {
        /**
         * 小程序消息标题，最多64个字节
         */ /**
         * title : 消息标题
         * pic_media_id : MEDIA_ID
         * appid : wx8bd80126147dfAAA
         * page : /path/index.html
         */

        @JSONField(name = "title")
        private String title;
        /**
         * 小程序消息封面的mediaid，封面图建议尺寸为520*416
         */
        @JSONField(name = "pic_media_id")
        private String picMediaId;
        /**
         * 小程序appid，必须是关联到企业的小程序应用
         */
        @JSONField(name = "appid")
        private String appid;
        /**
         * 小程序page路径
         */
        @JSONField(name = "page")
        private String page;

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getPicMediaId() {
            return picMediaId;
        }

        public void setPicMediaId(String picMediaId) {
            this.picMediaId = picMediaId;
        }

        public String getAppid() {
            return appid;
        }

        public void setAppid(String appid) {
            this.appid = appid;
        }

        public String getPage() {
            return page;
        }

        public void setPage(String page) {
            this.page = page;
        }
    }

    @Override
    public String toString() {
        return "AddMsgTemplateRequest{" +
                "accessToken='" + accessToken + '\'' +
                ", chatType='" + chatType + '\'' +
                ", externalUserid=" + externalUserid +
                ", sender='" + sender + '\'' +
                ", text=" + text +
                ", image=" + image +
                ", link=" + link +
                ", miniprogram=" + miniprogram +
                '}';
    }
}
